//
//  HCCallInfoTableViewCell.m
//  HelloCall
//
//  Created by WangYongpeng on 13-9-21.
//  Copyright (c) 2013年 HC. All rights reserved.
//

#import "HCComMenuCell.h"

@interface HCComMenuCell ()

@property (nonatomic, retain) UIButton* remarkButton;
@property (nonatomic, retain) UIButton* detailButton;
@property (nonatomic, retain) UIButton* changeStateButton;
@property (nonatomic, retain) UIButton* callPhoneButton;

@end

@implementation HCComMenuCell

@synthesize remarkButton = m_remarkButton;
@synthesize detailButton = m_detailButton;
@synthesize changeStateButton = m_changeStateButton;
@synthesize callPhoneButton = m_callPhoneButton;
@synthesize delegate = m_delegate;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        UIImage* bgImage = [UIImage imageNamed:@"CRMListChangeBg.png"];
        UIImageView* bgImageView = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 480, 43)] autorelease];
        bgImageView.image = [bgImage resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
        [self addSubview:bgImageView];

        
        UIImage* buttonImage = [[UIImage imageNamed:@"CRMListChangeButton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
        UIImage* buttonPressImage = [[UIImage imageNamed:@"CRMListChangeButtonPress.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
        
        self.detailButton = [[UIButton alloc] initWithFrame:CGRectMake(20, 11, 50, 20)];
//        self.detailButton.backgroundColor = [UIColor orangeColor];
        [self.detailButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
        [self.detailButton setBackgroundImage:buttonPressImage forState:UIControlStateHighlighted];
        [self.detailButton setTitle:@"详情" forState:UIControlStateNormal];
        [self.detailButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self.detailButton setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
        [self.detailButton addTarget:self action:@selector(detailButtonPress:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.detailButton];
        
        self.remarkButton = [[UIButton alloc] initWithFrame:CGRectMake(80, 11, 50, 20)];
//        self.remarkButton.backgroundColor = [UIColor orangeColor];
        [self.remarkButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
        [self.remarkButton setBackgroundImage:buttonPressImage forState:UIControlStateHighlighted];
        [self.remarkButton setTitle:@"备注" forState:UIControlStateNormal];
        [self.remarkButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self.remarkButton setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
        [self.remarkButton addTarget:self action:@selector(remarkButtonPress:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.remarkButton];
        
        self.changeStateButton = [[UIButton alloc] initWithFrame:CGRectMake(140, 11, 100, 20)];
//        self.changeStateButton.backgroundColor = [UIColor orangeColor];
        [self.changeStateButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
        [self.changeStateButton setBackgroundImage:buttonPressImage forState:UIControlStateHighlighted];
        [self.changeStateButton setTitle:@"状态变化" forState:UIControlStateNormal];
        [self.changeStateButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self.changeStateButton setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
        [self.changeStateButton addTarget:self action:@selector(changeStateButtonPress:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.changeStateButton];
        
        self.callPhoneButton = [[UIButton alloc] initWithFrame:CGRectMake(250, 11, 50, 20)];
//        self.callPhoneButton.backgroundColor = [UIColor orangeColor];
        [self.callPhoneButton setBackgroundImage:buttonImage forState:UIControlStateNormal];
        [self.callPhoneButton setBackgroundImage:buttonPressImage forState:UIControlStateHighlighted];
        [self.callPhoneButton setTitle:@"呼叫" forState:UIControlStateNormal];
        [self.callPhoneButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self.callPhoneButton setTitleColor:[UIColor blueColor] forState:UIControlStateHighlighted];
        [self.callPhoneButton addTarget:self action:@selector(callPhoneButtonPress:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.callPhoneButton];
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)dealloc
{
    self.remarkButton = nil;
    self.detailButton = nil;
    self.changeStateButton = nil;
    self.callPhoneButton = nil;
    
    [super dealloc];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)detailButtonPress:(UIButton*)button
{
    if ([self.delegate respondsToSelector:@selector(showDetail)])
    {
        [self.delegate showDetail];
    }
}

- (void)remarkButtonPress:(UIButton*)button
{
    if ([self.delegate respondsToSelector:@selector(showRemark)])
    {
        [self.delegate showRemark];
    }
}

- (void)changeStateButtonPress:(UIButton*)button
{
    if ([self.delegate respondsToSelector:@selector(changeState)])
    {
        [self.delegate changeState];
    }
}

- (void)callPhoneButtonPress:(UIButton*)button
{
    if ([self.delegate respondsToSelector:@selector(callPhone)])
    {
        [self.delegate callPhone];
    }
}

@end
